projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
37b3325
)
i2c: Fix pca953x endianess issue
author
Dirk Eibach
<
[email protected]
>
Thu, 29 Oct 2015 12:51:27 +0000
(13:51 +0100)
committer
Tom Rini
<
[email protected]
>
Thu, 12 Nov 2015 23:04:12 +0000
(18:04 -0500)
By reading 2 consecutive bytes from i2c to an u16 value
we have an endianess issue.
Signed-off-by: Dirk Eibach <
[email protected]
>
drivers/gpio/pca953x.c
patch
|
blob
|
history
diff --git
a/drivers/gpio/pca953x.c
b/drivers/gpio/pca953x.c
index 7371cd4a87fdd7b7a64afbb39ed4fd80e402d6cc..c8c863765b6db72b86c2e6c468c518c3168b259f 100644
(file)
--- a/
drivers/gpio/pca953x.c
+++ b/
drivers/gpio/pca953x.c
@@
-88,8
+88,10
@@
static int pca953x_reg_write(uint8_t chip, uint addr, uint mask, uint data)
if (i2c_read(chip, addr << 1, 1, (u8*)&valw, 2))
return -1;
+ valw = le16_to_cpu(valw);
valw &= ~mask;
valw |= data;
+ valw = cpu_to_le16(valw);
return i2c_write(chip, addr << 1, 1, (u8*)&valw, 2);
}
@@
-107,7
+109,7
@@
static int pca953x_reg_read(uint8_t chip, uint addr, uint *data)
} else {
if (i2c_read(chip, addr << 1, 1, (u8*)&valw, 2))
return -1;
- *data = (
int)valw
;
+ *data = (
uint)le16_to_cpu(valw)
;
}
return 0;
}